package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

//查找一本书
public class FindQperation implements IOperation {
//    传一个书架
    @Override
    public void word(BookList bookList){
        System.out.println("查找书籍");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要查找的书名：");
        String name = scanner.nextLine();
        for(int i = 0;i < bookList.getUsedSize(); i++){
            Book book = bookList.getBook(i);
//            字符串的比较要通过equals（）；
            if(name.equals(book.getName())){
                System.out.println("找到此书如下：");
                System.out.println(book);
                return;
            }
        }
        System.out.println("无此书");
    }
}
